<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>bosdyn.client.lease &mdash; Spot 5.0.1.1 documentation</title>
      <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/style.css" type="text/css" />
    <link rel="shortcut icon" href="../../../_static/bd-favicon.png"/>
    <link rel="canonical" href="https://dev.bostondynamics.com/_modules/bosdyn/client/lease.html" />
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../README.html">
            
              <img src="../../../_static/bd-official-white.png" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                5.0.1.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/concepts/README.html">Concepts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/about_spot.html">About Spot</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/orbit/about_orbit.html">About Orbit (formerly Scout)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/orbit/orbit_api.html">Orbit API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/networking.html">Networking</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/base_services.html">Base services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/geometry_and_frames.html">Geometry and Frames</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/robot_services.html">Robot services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/estop_service.html">E-Stop</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/keepalive_service.html">KeepAlive (BETA)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/audio_visual.html">Audio Visual</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/lease_service.html">Lease</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/developing_api_services.html">Developing API Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/service_customization.html">Service Customization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/faults.html">Faults</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/autonomy/README.html">Autonomy services</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_tech_summary.html">Autonomy Technical Summary</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autonomous_navigation_code_examples.html">Autonomous navigation code examples</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/components_of_autonomous_navigation.html">Components of autonomous navigation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/docking.html">Docking</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/typical_autonomous_navigation_use_case.html">Typical autonomous navigation use case</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autonomous_navigation_services.html">Autonomous navigation services</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_service.html">GraphNav service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_map_structure.html">GraphNav map structure</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_area_callbacks.html">GraphNav area callbacks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/initialization.html">Initialization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/localization.html">Localization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_and_robot_locomotion.html">GraphNav and robot locomotion</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/missions_service.html">Missions service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autowalk_service.html">Autowalk service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/network_compute_bridge.html">Network compute bridge</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/auto_return.html">AutoReturn service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/directed_exploration.html">Directed Exploration</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/gps.html">GPS</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/choreography/README.html">Choreography</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_service.html">Choreography Service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/move_reference.html">Move Reference Guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/custom_gait.html">CustomGait Reference</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreographer_setup.html">Choreographer Setup</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreographer.html">Choreographer Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/robot_controls_in_choreographer.html">Robot Connections in Choreographer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/animations_in_choreographer.html">Animations in Choreography</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/animation_file_specification.html">Animation File Format</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_in_tablet.html">Tablet Choreography Mode</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_in_autowalk.html">Choreography Actions in Autowalk</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/joint_control/README.html">Joint Control API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/joint_control/supplemental_data.html">Supplemental Robot Information</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../docs/concepts/joint_control/knee_torque_limits.html">Knee Torque Limits</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/arm/README.html">Spot Arm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_specification.html">Arm and Gripper Specification</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_concepts.html">Concepts</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_services.html">Services</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/data.html">Spot Data</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_overview.html">Data Acquisition Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_output.html">Data Acquisition Output</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/writing_services_for_data_acquisition.html">Integrate Payloads with the API</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_buffer_overview.html">Data Buffer Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/bddf.html">BDDF File Format</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_thermal_raw.html">Thermal Raw Data Format</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/python/README.html">Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/quickstart.html">Quickstart</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/understanding_spot_programming.html">Understanding Spot Programming</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../python/examples/README.html">Examples</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/basic_service_examples.html">Basic Service Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/hello_spot/README.html">Hello Spot</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/directory/README.html">Directory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_robot_state/README.html">Get Robot State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_robot_state_async/README.html">Get Robot State Async</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_world_objects/README.html">Get World Objects</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_mission_state/README.html">Get Mission State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/estop/README.html">E-Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/time_sync/README.html">Time Sync</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_test/README.html">Comms Test</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/disable_ir_emission/README.html">IR Enable/Disable</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/reset_safety_stop/README.html">Reset Safety Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/audio_visual/audio_visual_params/README.html">Audio Visual Params</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/audio_visual/audio_visual_behaviors/README.html">Audio Visual Behaviors</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/robot_behavior_examples.html">Robot Behavior and Commands Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/stance/README.html">Stance</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/frame_trajectory_command/README.html">Frame Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_light/README.html">Spot Light</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/upload_choreographed_sequence/README.html">Upload Choreographed Sequence</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/xbox_controller/README.html">Xbox Controller</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/wasd/README.html">WASD</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/docking/README.html">Docking</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/animation_recorder/README.html">Animation Recorder</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/auto_return/README.html">Auto Return</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/fan_command/README.html">Fan Commands</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_wasd/README.html">ARM WASD</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/arm_examples.html">Arm Command Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_simple/README.html">Simple Arm Motion</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_stow_unstow/README.html">Stow/unstow Arm</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_freeze/README.html">Arm Freeze</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_and_mobility_command/README.html">Arm and Mobility Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_with_body_follow/README.html">Arm Command with Body Following</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_constrained_manipulation/README.html">Arm Constrained Manipulation</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_trajectory/README.html">Arm Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_trajectory/README.html#long-trajectory">Long Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_joint_move/README.html">Arm Joint Move Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_force_control/README.html">Arm Force Control Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_grasp/README.html">Arm Grasp Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_grasp_carry_overrides/README.html">Arm Grasp and Carry Overrides</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_gaze/README.html">Arm Gaze Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_surface_contact/README.html">Arm Command with Surface Contact</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_door/README.html">Arm Door Opening Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_walk_to_object/README.html">Walk to And Pick Up Object</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_gcode/README.html">Writing Gcode</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gripper_camera_params/README.html">Gripper Camera Parameters</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_impedance_control/README.html">Arm Impedance Control</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/inverse_kinematics/README.html">Inverse Kinematics</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_wasd/README.html">Arm WASD</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/joint_control/README.html">Wiggle Arm</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/payloads_examples.html">Payloads and Registration Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/payloads/README.html">Payloads</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/self_registration/README.html">Self Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_faults/README.html">Faults</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/velodyne_client/README.html">Velodyne</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/core_io_gpio/README.html">CORE I/O GPIO</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html">Overview</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#usage">Usage</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#components">Components</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#recommended-debugging">Recommended debugging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/extensions/README.html">Extensions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/perception_world_objects_examples.html">Perception and World Objects Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_world_objects/README.html">Get World Objects</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/world_object_with_image_coordinates/README.html">World Object With Image Coordinates</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/world_object_mutations/README.html">World Object Mutations</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/visualizer/README.html">Visualizer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gripper_camera_params/README.html">Gripper Camera Parameters</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_cam/README.html">Spot CAM Services</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_cam/README.html#spot-cam-video-core-io-extension-example">Spot Cam Video Core IO Extension Example</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/stitch_front_images/README.html">Stitch Front Images</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_depth_plus_visual_image/README.html">Project Depth Data on Visual Images</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_image_server/README.html">Custom Parameter Image Server</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/fiducial_follow/README.html">Fiducial Follow</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_tensorflow_detector/README.html">Tensorflow Detector</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_ncb_worker/README.html">Custom Parameter Tensorflow Detector</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_compute_bridge/README.html">Machine Learning with the Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_compute_bridge/fire_extinguisher_server/README.html">Fire Extinguisher Detector with the Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/ray_cast/README.html">Ray Cast</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/user_nogo_regions/README.html">No-Go Regions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gps_service/README.html">GPS</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/logging_examples.html">Logging Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/bddf_download/README.html">BDDF Download</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_buffer/README.html">Data Buffer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_service/README.html">Data Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/logging/README.html">Logging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/log_status/README.html">Log Status</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/data_acquisition_examples.html">Data Acquisition Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_acquisition_service/README.html">Data Acquisition Service</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/examples/data_acquisition_service/signals_coreio_modem_plugin/README.html">Modem Signals</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_faults/README.html">Faults</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_image_server/README.html">Custom Parameter Image Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameters_data_acquisition/README.html">Custom Parameter Data Acquisition Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Test Image Service Implementation with Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/post_docking_callbacks/README.html">Post Docking Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/cloud_upload/README.html">Cloud Upload</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_mapping/README.html">Comms image service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_mapping/README.html#how-to-use">How to use</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_acquisition_service/signals_coreio_modem_plugin/README.html">CoreIO Modem Signals Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/tester_programs/README.html">Tester Programs</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/autonomy_and_missions_examples.html">Autonomy and Missions Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_anchoring_optimization/README.html">Graph Nav Anchoring Optimization</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_command_line/README.html">GraphNav and Recording Service Command Line Interfaces</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_command_line/README.html#example-programs">Example Programs</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_extract_point_cloud/README.html">Graph Nav Extract Point Cloud</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_view_map/README.html">Graph Nav View Map</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_view_gps/README.html">Graph Nav View GPS Data</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_mission_state/README.html">Get Mission State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/remote_mission_service/README.html">Remote Mission Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/mission_question_answerer/README.html">Mission Question Answerer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/mission_recorder/README.html">Mission Recorder</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/replay_mission/README.html">Replay Mission</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/post_docking_callbacks/README.html">Post Docking Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/area_callback/README.html">Area Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/edit_autowalk/README.html">Edit Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/record_autowalk/README.html">Record Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/extract_images_from_walk/README.html">Extract Images from Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_request_callback/README.html">Network Request Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_request_callback/README.html#id1">Network Request Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/remote_mission_service/spot_check/README.html">SpotCheck Mission Service</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/joint_control_examples.html">Joint Control API Examples</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/orbit.html">Orbit</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/hello_orbit/README.html">Hello Orbit</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/export_run_archives/README.html">Export Run Archives</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/export_site_walk_archives/README.html">Export Sitewalk Archives</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/anomalies/README.html">Anomalies</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/schedule_mission/README.html">Schedule Mission</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/runs_response/README.html">Runs Response</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/send_robot_back_to_dock/README.html">Return to Dock</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/toggle_mission_based_on_weather/README.html">Mission Toggle</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook/README.html">Webhook</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/backups/README.html">Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook_integration/README.html">Webhook Integrations</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook_integration/README.html#example-overview">Example Overview</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../python/README.html">Python Reference Guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/README.html">Client</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback.html">Area Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_region_handler_base.html">Area Callback Region Handler</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_runner.html">Area Callback Service Runner</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_servicer.html">Area Callback Servicer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_utils.html">Area Callback Service Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/arm_surface_contact.html">Arm Surface Contact</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/async_tasks.html">Async Tasks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/audio_visual.html">Audio Visual</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/audio_visual_helpers.html">Audio Visual Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/auth.html">Auth</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/auto_return.html">Auto Return</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/autowalk.html">Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/bddf.html">BDDF</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/bddf_download.html">BDDF Download</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/channel.html">Channel</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html">Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/common.html">Common</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition.html">Data Acquisition</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_helpers.html">Data Acquisition Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_plugin.html">Data Acquisition Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_plugin_service.html">Data Acquisition Plugin Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_store.html">Data Acquisition Store</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_buffer.html">Data Buffer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_chunk.html">Data Chunk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_service.html">Data Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/directory_registration.html">Directory Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/directory.html">Directory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/docking.html">Docking</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/door.html">Door</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/estop.html">E-Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/error_callback_result.html">Error Callback Result</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/exceptions.html">Exceptions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/fault.html">Fault</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/frame_helpers.html">Frame Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/graph_nav.html">Graph Nav</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gripper_camera_param.html">Gripper Camera Params</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/README.html">GPS</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/aggregator_client.html">Aggregator Client</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/gps_listener.html">GPS Listener</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/NMEAParser.html">NMEA Parser</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/ntrip_client.html">NTRIP Client</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/registration_client.html">Registration Client</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/image.html">Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/image_service_helpers.html">Image Service Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/inverse_kinematics.html">Inverse Kinematics</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/ir_enable_disable.html">IR Enable/Disable</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/keepalive.html">Keep Alive</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html">Lease</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease_resource_hierarchy.html">Lease Resource Hierarchy</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease_validator.html">Lease Validator</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/license.html">License</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/local_grid.html">Local Grid</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/log_status.html">Log Status</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/math_helpers.html">Math Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/manipulation_api_client.html">Manipulation API</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/map_processing.html">Map Processing</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/metrics_logging.html">Metrics Logging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/network_compute_bridge_client.html">Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_registration.html">Payload Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_software_update.html">Payload Software Update</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_software_update_initiation.html">Payload Software Update Initiation</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload.html">Payload</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/point_cloud.html">Point Cloud</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/power.html">Power</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/processors.html">Processors</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/ray_cast.html">Ray casting</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/recording.html">Recording</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_command.html">Robot Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_id.html">Robot ID</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot.html">Robot</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_state.html">Robot State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/sdk.html">SDK</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/server_util.html">Server Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/service_customization_helpers.html">Service Customization Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/signals_helpers.html">Signals Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/README.html">Spot CAM</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/audio.html">Audio</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/compositor.html">Compositor</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/health.html">Health</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/lighting.html">Lighting</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/lights_helper.html">Lights Helper</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/media_log.html">Media Log</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/network.html">Network</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/power.html">Power</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/ptz.html">PTZ</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/streamquality.html">Stream Quality</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/version.html">Version</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_check.html">Spot Check</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/time_sync.html">Time Sync</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/token_cache.html">Token Cache</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/token_manager.html">Token Manager</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/units_helpers.html">Units Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/util.html">Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/world_object.html">World Object</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/README.html">Core</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/README.html">BDDF</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/base_data_reader.html">Base Data Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/block_writer.html">Block Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/bosdyn.html">BDDF Conventions</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/common.html">Common</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/data_reader.html">Data Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/data_writer.html">Data Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/file_indexer.html">File Indexer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_proto_reader.html">GRPC Proto Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_reader.html">GRPC Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_service_reader.html">GRPC Service Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_service_writer.html">GRPC Service Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/message_reader.html">Message Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/pod_series_reader.html">POD Series Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/pod_series_writer.html">POD Series Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_channel_reader.html">Protobuf Channel Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_reader.html">Protobuf Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_series_writer.html">Protobuf Series Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/stream_data_reader.html">Stream Data Reader</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/geometry.html">Geometry</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/util.html">Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/deprecated.html">Deprecated</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/README.html">Mission</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/constants.html">Constants</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/exceptions.html">Exceptions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/remote_client.html">Remote Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/server_util.html">Server Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/util.html">Util</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/README.html">Choreography</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/choreography.html">Choreography</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/animation_file_to_proto.html">Animation File to Proto</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/animation_file_conversion_helpers.html">Animation File to Proto Helpers</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/README.html">Orbit (formerly Scout)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/utils.html">Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/exceptions.html">Exceptions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/README.html">Scout (deprecated)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/utils.html">Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/exceptions.html">Exceptions</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch1.html">Fetch Tutorial</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch2.html">Part 2: Training the Model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch3.html">Part 3: Evaluating the Model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch4.html">Part 4: Autonomous Pick Up</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch5.html">Part 5: Detecting People and Playing Fetch</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch6.html">Part 6: Running the model on Core IO</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq1.html">Data Collection Tutorial</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq2.html">Part 2: Capturing images</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq3.html">Part 3: Capturing other data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq4.html">Part 4: Deploying to the CORE I/O</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq5.html">Part 5: Collecting data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq6.html">Part 6: Processing collected data</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/payload/README.html">Payloads</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/payload_configuration_requirements.html">Payload configuration requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/mechanical_interfaces.html">Mechanical interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/robot_mounting_rails.html">Robot mounting rails</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/guidelines_for_robust_payload_design.html">Guidelines for robust payload design</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/robot_electrical_interface.html">Robot electrical interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/coreio_documentation.html">CORE I/O Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/coreio_openvpn_extension.html">CORE I/O OpenVPN Extension</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/configuring_payload_software.html">Configuring payload software</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/docker_containers.html">Dockerize payload software</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/spot_core_documentation.html">Pre-3.2 Spot CORE Documentation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_portainer.html">Configuring Docker containers in SpotCORE</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_cockpit.html">Spot CORE system management tool: Cockpit</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_vnc.html">Spot CORE VNC</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/protos/README.html">API Protocol</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/protos/style_guide.html">Style Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../protos/bosdyn/api/README.html">Proto Reference Guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../protos/bosdyn/api/proto_reference.html">Protos</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/release_notes.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/boston-dynamics/spot-sdk">SDK Repository</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../README.html">Spot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../README.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
      <li class="breadcrumb-item active">bosdyn.client.lease</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for bosdyn.client.lease</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) 2023 Boston Dynamics, Inc.  All rights reserved.</span>
<span class="c1">#</span>
<span class="c1"># Downloading, reproducing, distributing or otherwise using the SDK Software</span>
<span class="c1"># is subject to the terms and conditions of the Boston Dynamics Software</span>
<span class="c1"># Development Kit License (20191101-BDSDK-SL).</span>

<span class="sd">&quot;&quot;&quot;Lease clients&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">enum</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span> <span class="nn">time</span>

<span class="kn">from</span> <span class="nn">bosdyn.api</span> <span class="kn">import</span> <span class="n">lease_pb2</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.lease_pb2</span> <span class="kn">import</span> <span class="n">AcquireLeaseRequest</span><span class="p">,</span> <span class="n">AcquireLeaseResponse</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.lease_pb2</span> <span class="kn">import</span> <span class="n">Lease</span> <span class="k">as</span> <span class="n">LeaseProto</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.lease_pb2</span> <span class="kn">import</span> <span class="p">(</span><span class="n">LeaseUseResult</span><span class="p">,</span> <span class="n">ListLeasesRequest</span><span class="p">,</span> <span class="n">RetainLeaseRequest</span><span class="p">,</span>
                                  <span class="n">ReturnLeaseRequest</span><span class="p">,</span> <span class="n">ReturnLeaseResponse</span><span class="p">,</span> <span class="n">TakeLeaseRequest</span><span class="p">,</span>
                                  <span class="n">TakeLeaseResponse</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.lease_service_pb2_grpc</span> <span class="kn">import</span> <span class="n">LeaseServiceStub</span>

<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">common</span>
<span class="kn">from</span> <span class="nn">.exceptions</span> <span class="kn">import</span> <span class="n">Error</span> <span class="k">as</span> <span class="n">BaseError</span>
<span class="kn">from</span> <span class="nn">.exceptions</span> <span class="kn">import</span> <span class="n">ResponseError</span><span class="p">,</span> <span class="n">RpcError</span>

<span class="n">_LOGGER</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="LeaseResponseError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseResponseError">[docs]</a><span class="k">class</span> <span class="nc">LeaseResponseError</span><span class="p">(</span><span class="n">ResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;General class of errors for LeaseResponseError service.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="InvalidLeaseError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.InvalidLeaseError">[docs]</a><span class="k">class</span> <span class="nc">InvalidLeaseError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;The provided lease is invalid.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="DisplacedLeaseError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.DisplacedLeaseError">[docs]</a><span class="k">class</span> <span class="nc">DisplacedLeaseError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Lease is older than the current lease.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="InvalidResourceError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.InvalidResourceError">[docs]</a><span class="k">class</span> <span class="nc">InvalidResourceError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Resource is not known to the LeaseService.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="NotAuthoritativeServiceError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.NotAuthoritativeServiceError">[docs]</a><span class="k">class</span> <span class="nc">NotAuthoritativeServiceError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;LeaseService is not authoritative so Acquire should not work.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="ResourceAlreadyClaimedError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.ResourceAlreadyClaimedError">[docs]</a><span class="k">class</span> <span class="nc">ResourceAlreadyClaimedError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Use TakeLease method to forcefully grab the already claimed lease.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="RevokedLeaseError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.RevokedLeaseError">[docs]</a><span class="k">class</span> <span class="nc">RevokedLeaseError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Lease is stale because the lease-holder did not check in regularly enough.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="UnmanagedResourceError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.UnmanagedResourceError">[docs]</a><span class="k">class</span> <span class="nc">UnmanagedResourceError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;LeaseService does not manage this resource.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="WrongEpochError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.WrongEpochError">[docs]</a><span class="k">class</span> <span class="nc">WrongEpochError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Lease is for the wrong epoch.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="NotActiveLeaseError"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.NotActiveLeaseError">[docs]</a><span class="k">class</span> <span class="nc">NotActiveLeaseError</span><span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Lease is not the active lease.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="Error"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Error">[docs]</a><span class="k">class</span> <span class="nc">Error</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Base non-response error for lease module.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="NoSuchLease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.NoSuchLease">[docs]</a><span class="k">class</span> <span class="nc">NoSuchLease</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;The requested lease does not exist.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">resource</span> <span class="o">=</span> <span class="n">resource</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;No lease for resource &quot;</span><span class="si">{}</span><span class="s1">&quot;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resource</span><span class="p">)</span></div>


<div class="viewcode-block" id="LeaseNotOwnedByWallet"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseNotOwnedByWallet">[docs]</a><span class="k">class</span> <span class="nc">LeaseNotOwnedByWallet</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;The lease is not owned by the wallet.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="p">,</span> <span class="n">lease_state</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">resource</span> <span class="o">=</span> <span class="n">resource</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_state</span> <span class="o">=</span> <span class="n">lease_state</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">state</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_state</span><span class="o">.</span><span class="n">lease_status</span>
        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
            <span class="n">state</span> <span class="o">=</span> <span class="s1">&#39;&lt;unknown&gt;&#39;</span>
        <span class="k">return</span> <span class="s1">&#39;Lease on &quot;</span><span class="si">{}</span><span class="s1">&quot; has state (</span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resource</span><span class="p">,</span> <span class="n">state</span><span class="p">)</span></div>


<span class="n">_ACQUIRE_LEASE_STATUS_TO_ERROR</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="p">(</span><span class="n">ResponseError</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span>
<span class="n">_ACQUIRE_LEASE_STATUS_TO_ERROR</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
    <span class="n">AcquireLeaseResponse</span><span class="o">.</span><span class="n">STATUS_OK</span><span class="p">:</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
    <span class="n">AcquireLeaseResponse</span><span class="o">.</span><span class="n">STATUS_RESOURCE_ALREADY_CLAIMED</span><span class="p">:</span>
        <span class="p">(</span><span class="n">ResourceAlreadyClaimedError</span><span class="p">,</span> <span class="n">ResourceAlreadyClaimedError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
    <span class="n">AcquireLeaseResponse</span><span class="o">.</span><span class="n">STATUS_INVALID_RESOURCE</span><span class="p">:</span>
        <span class="p">(</span><span class="n">InvalidResourceError</span><span class="p">,</span> <span class="n">InvalidResourceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
    <span class="n">AcquireLeaseResponse</span><span class="o">.</span><span class="n">STATUS_NOT_AUTHORITATIVE_SERVICE</span><span class="p">:</span>
        <span class="p">(</span><span class="n">NotAuthoritativeServiceError</span><span class="p">,</span> <span class="n">NotAuthoritativeServiceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
<span class="p">})</span>

<span class="n">_TAKE_LEASE_STATUS_TO_ERROR</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="p">(</span><span class="n">ResponseError</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span>
<span class="n">_TAKE_LEASE_STATUS_TO_ERROR</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
    <span class="n">TakeLeaseResponse</span><span class="o">.</span><span class="n">STATUS_OK</span><span class="p">:</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
    <span class="n">TakeLeaseResponse</span><span class="o">.</span><span class="n">STATUS_INVALID_RESOURCE</span><span class="p">:</span> <span class="p">(</span><span class="n">InvalidResourceError</span><span class="p">,</span> <span class="n">InvalidResourceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
    <span class="n">TakeLeaseResponse</span><span class="o">.</span><span class="n">STATUS_NOT_AUTHORITATIVE_SERVICE</span><span class="p">:</span>
        <span class="p">(</span><span class="n">NotAuthoritativeServiceError</span><span class="p">,</span> <span class="n">NotAuthoritativeServiceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
<span class="p">})</span>

<span class="n">_RETURN_LEASE_STATUS_TO_ERROR</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="p">(</span><span class="n">ResponseError</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span>
<span class="n">_RETURN_LEASE_STATUS_TO_ERROR</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
    <span class="n">ReturnLeaseResponse</span><span class="o">.</span><span class="n">STATUS_OK</span><span class="p">:</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span>
    <span class="n">ReturnLeaseResponse</span><span class="o">.</span><span class="n">STATUS_INVALID_RESOURCE</span><span class="p">:</span>
        <span class="p">(</span><span class="n">InvalidResourceError</span><span class="p">,</span> <span class="n">InvalidResourceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
    <span class="n">ReturnLeaseResponse</span><span class="o">.</span><span class="n">STATUS_NOT_ACTIVE_LEASE</span><span class="p">:</span> <span class="p">(</span><span class="n">NotActiveLeaseError</span><span class="p">,</span> <span class="n">NotActiveLeaseError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
    <span class="n">ReturnLeaseResponse</span><span class="o">.</span><span class="n">STATUS_NOT_AUTHORITATIVE_SERVICE</span><span class="p">:</span>
        <span class="p">(</span><span class="n">NotAuthoritativeServiceError</span><span class="p">,</span> <span class="n">NotAuthoritativeServiceError</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">),</span>
<span class="p">})</span>


<div class="viewcode-block" id="Lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease">[docs]</a><span class="k">class</span> <span class="nc">Lease</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Leases are used to coordinate access to shared resources on a Boston Dynamics robot.</span>

<span class="sd">    A service will grant access to the shared resource if the lease which accompanies a request is</span>
<span class="sd">    &quot;more recent&quot; than any previously seen leases. Recency is determined using a sequence of</span>
<span class="sd">    monotonically increasing numbers, similar to a Lamport logical clock.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_proto: bosdyn.api.Lease protobuf object.</span>
<span class="sd">    Raises:</span>
<span class="sd">        ValueError if lease_proto is not present or valid.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_proto</span><span class="p">,</span> <span class="n">ignore_is_valid_check</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">ignore_is_valid_check</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_valid_proto</span><span class="p">(</span><span class="n">lease_proto</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;invalid lease_proto: </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lease_proto</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span> <span class="o">=</span> <span class="n">lease_proto</span>

<div class="viewcode-block" id="Lease.CompareResult"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.CompareResult">[docs]</a>    <span class="k">class</span> <span class="nc">CompareResult</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Enum for comparison results between two leases.&quot;&quot;&quot;</span>
        <span class="n">SAME</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="n">SUPER_LEASE</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="n">SUB_LEASE</span> <span class="o">=</span> <span class="mi">3</span>
        <span class="n">OLDER</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="n">NEWER</span> <span class="o">=</span> <span class="mi">5</span>
        <span class="n">DIFFERENT_RESOURCES</span> <span class="o">=</span> <span class="mi">6</span>
        <span class="n">DIFFERENT_EPOCHS</span> <span class="o">=</span> <span class="mi">7</span></div>

<div class="viewcode-block" id="Lease.compare"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.compare">[docs]</a>    <span class="k">def</span> <span class="nf">compare</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other_lease</span><span class="p">,</span> <span class="n">ignore_resources</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Compare two different lease objects.</span>

<span class="sd">        Args:</span>
<span class="sd">            other_lease: The lease to compare this lease with.</span>

<span class="sd">        Returns:</span>
<span class="sd">            * CompareResult.SAME if this lease is exactly the same as other_lease.</span>
<span class="sd">            * CompareResult.SUPER_LEASE if this lease is a &quot;super-lease&quot; of the other</span>
<span class="sd">              lease - in other words, the other lease is a sublease of this lease.</span>
<span class="sd">            * CompareResult.SUB_LEASE if this lease is a &quot;sub-lease&quot; of the other lease.</span>
<span class="sd">            * CompareResult.OLDER if this lease is older than other_lease.</span>
<span class="sd">              other_lease may be a sublease of this lease.</span>
<span class="sd">            * CompareResult.NEWER if this is lease is newer than other_lease. This</span>
<span class="sd">              lease may be a sublease of other_lease.</span>
<span class="sd">            * CompareResult.DIFFERENT_RESOURCES if this lease is for a different</span>
<span class="sd">              resource than other_lease. There is no way to compare recency/time of</span>
<span class="sd">              Leases for two different resources.</span>
<span class="sd">            * CompareResult.DIFFERENT_EPOCHS if this lease is for a different</span>
<span class="sd">              epoch than other_lease. There is no way to compare recency/time of</span>
<span class="sd">              Leases for two different epochs.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Sequences are only valid for leases with the same resource and epoch.</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">resource</span>
                <span class="o">==</span> <span class="n">other_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">resource</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">ignore_resources</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">DIFFERENT_RESOURCES</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">epoch</span> <span class="o">==</span> <span class="n">other_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">epoch</span><span class="p">):</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">DIFFERENT_EPOCHS</span>

        <span class="c1"># If any sequence numbers are different within the common subset of sequence lengths, then one</span>
        <span class="c1"># Lease is newer than the other.</span>
        <span class="n">sequence_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">)</span>
        <span class="n">other_sequence_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">other_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">)</span>
        <span class="n">common_sequence_size</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">sequence_size</span><span class="p">,</span> <span class="n">other_sequence_size</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">common_sequence_size</span><span class="p">):</span>
            <span class="n">sequence_num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
            <span class="n">other_sequence_num</span> <span class="o">=</span> <span class="n">other_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">sequence_num</span> <span class="o">&lt;</span> <span class="n">other_sequence_num</span><span class="p">:</span>
                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">OLDER</span>
            <span class="k">elif</span> <span class="n">sequence_num</span> <span class="o">&gt;</span> <span class="n">other_sequence_num</span><span class="p">:</span>
                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">NEWER</span>

        <span class="c1"># At this point, the sequence numbers are different within the common subset. If one Lease has</span>
        <span class="c1"># more sequence numbers than the other Lease, it is a sublease of that lease and considered</span>
        <span class="c1"># newer.</span>
        <span class="k">if</span> <span class="n">sequence_size</span> <span class="o">&lt;</span> <span class="n">other_sequence_size</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SUPER_LEASE</span>
        <span class="k">elif</span> <span class="n">sequence_size</span> <span class="o">&gt;</span> <span class="n">other_sequence_size</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SUB_LEASE</span>

        <span class="c1"># Lease are the same</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SAME</span></div>

<div class="viewcode-block" id="Lease.create_newer"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.create_newer">[docs]</a>    <span class="k">def</span> <span class="nf">create_newer</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Creates a new Lease which is newer than this Lease.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A new Lease object where self.compare(returned_lease) would return OLDER.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">incr_lease_proto</span> <span class="o">=</span> <span class="n">LeaseProto</span><span class="p">()</span>
        <span class="n">incr_lease_proto</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
        <span class="n">incr_lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span>
        <span class="k">return</span> <span class="n">Lease</span><span class="p">(</span><span class="n">incr_lease_proto</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lease.create_sublease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.create_sublease">[docs]</a>    <span class="k">def</span> <span class="nf">create_sublease</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">client_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Creates a sublease of this lease.</span>

<span class="sd">        Args:</span>
<span class="sd">            client_name (string): Optional argument to pass a client name to be appended to</span>
<span class="sd">                                  the new lease&#39;s set of clients which have used it.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A new Lease object where self.compare(returned_lease) would return SUB_LEASE.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">sub_lease_proto</span> <span class="o">=</span> <span class="n">LeaseProto</span><span class="p">()</span>
        <span class="n">sub_lease_proto</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
        <span class="n">sub_lease_proto</span><span class="o">.</span><span class="n">sequence</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">client_name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">sub_lease_proto</span><span class="o">.</span><span class="n">client_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">client_name</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">Lease</span><span class="p">(</span><span class="n">sub_lease_proto</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lease.is_valid_lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.is_valid_lease">[docs]</a>    <span class="k">def</span> <span class="nf">is_valid_lease</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">Lease</span><span class="o">.</span><span class="n">is_valid_proto</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span></div>

<div class="viewcode-block" id="Lease.is_valid_proto"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.is_valid_proto">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">is_valid_proto</span><span class="p">(</span><span class="n">lease_proto</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Checks whether this lease is valid.</span>

<span class="sd">        Returns:</span>
<span class="sd">           bool indicating that this lease has a valid resource and sequence.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">lease_proto</span> <span class="ow">and</span> <span class="n">lease_proto</span><span class="o">.</span><span class="n">resource</span> <span class="ow">and</span> <span class="n">lease_proto</span><span class="o">.</span><span class="n">sequence</span></div>

<div class="viewcode-block" id="Lease.compare_result_to_lease_use_result_status"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.Lease.compare_result_to_lease_use_result_status">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">compare_result_to_lease_use_result_status</span><span class="p">(</span><span class="n">compare_result</span><span class="p">,</span> <span class="n">allow_super_leases</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Determines the comparable LeaseUseResult.Status enum value based on the CompareResult enum.</span>

<span class="sd">        Args:</span>
<span class="sd">            allow_super_leases(boolean): If true, a super lease will still be considered as &quot;ok&quot;/</span>
<span class="sd">                                     newer when compared to the active lease.</span>

<span class="sd">        Raises:</span>
<span class="sd">            bosdyn.client.lease.Error: Raised if there is an unknown compare result enum value.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The corresponding LeaseUseResult.Status enum value.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">DIFFERENT_EPOCHS</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_WRONG_EPOCH</span>
        <span class="k">elif</span> <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">DIFFERENT_RESOURCES</span><span class="p">:</span>
            <span class="c1"># if the incoming lease&#39;s resource doesn&#39;t match the active lease resource,</span>
            <span class="c1"># then mark it as unmanaged.</span>
            <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_UNMANAGED</span>
        <span class="k">elif</span> <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SUPER_LEASE</span><span class="p">:</span>
            <span class="c1"># In some cases we may want to allow a super lease, so check an optional boolean</span>
            <span class="c1"># to see if that is the case.</span>
            <span class="k">if</span> <span class="n">allow_super_leases</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OK</span>
            <span class="c1"># In the normal case, a super lease is considered older.</span>
            <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OLDER</span>
        <span class="k">elif</span> <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">OLDER</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OLDER</span>
        <span class="k">elif</span> <span class="p">(</span><span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SAME</span> <span class="ow">or</span>
              <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SUB_LEASE</span> <span class="ow">or</span>
              <span class="n">compare_result</span> <span class="o">==</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">NEWER</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OK</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Shouldn&#39;t hit here. The above set of checks should be exhaustive.</span>
            <span class="k">raise</span> <span class="n">Error</span><span class="p">(</span><span class="s2">&quot;The comparison result of the leases is unknown/unaccounted for.&quot;</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="LeaseState"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseState">[docs]</a><span class="k">class</span> <span class="nc">LeaseState</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;State of lease ownership in the wallet.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_status(LeaseState.Status): The ownership status of the lease.</span>
<span class="sd">        lease_owner(lease_pb2.LeaseOwner): The name of the owner of the lease.</span>
<span class="sd">        lease (Lease): The original lease used to initialize the LeaseState, before</span>
<span class="sd">                       applying any subleasing/incrementing.</span>
<span class="sd">        lease_current(Lease): The newest version of the lease (subleased, and</span>
<span class="sd">                              incremented from the original lease).</span>
<span class="sd">        client_name(string): The name of the client using this lease.</span>
<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="LeaseState.Status"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseState.Status">[docs]</a>    <span class="k">class</span> <span class="nc">Status</span><span class="p">(</span><span class="n">enum</span><span class="o">.</span><span class="n">Enum</span><span class="p">):</span>
        <span class="n">UNOWNED</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">REVOKED</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="n">SELF_OWNER</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="n">OTHER_OWNER</span> <span class="o">=</span> <span class="mi">3</span>
        <span class="n">NOT_MANAGED</span> <span class="o">=</span> <span class="mi">4</span></div>

    <span class="c1"># Deprecated. Provided for backwards compatibility.</span>
    <span class="n">STATUS_UNOWNED</span> <span class="o">=</span> <span class="n">Status</span><span class="o">.</span><span class="n">UNOWNED</span>
    <span class="n">STATUS_REVOKED</span> <span class="o">=</span> <span class="n">Status</span><span class="o">.</span><span class="n">REVOKED</span>
    <span class="n">STATUS_SELF_OWNER</span> <span class="o">=</span> <span class="n">Status</span><span class="o">.</span><span class="n">SELF_OWNER</span>
    <span class="n">STATUS_OTHER_OWNER</span> <span class="o">=</span> <span class="n">Status</span><span class="o">.</span><span class="n">OTHER_OWNER</span>
    <span class="n">STATUS_NOT_MANAGED</span> <span class="o">=</span> <span class="n">Status</span><span class="o">.</span><span class="n">NOT_MANAGED</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_status</span><span class="p">,</span> <span class="n">lease_owner</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">lease</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">lease_current</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">client_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">lease_status</span> <span class="o">=</span> <span class="n">lease_status</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_owner</span> <span class="o">=</span> <span class="n">lease_owner</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_original</span> <span class="o">=</span> <span class="n">lease</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">client_name</span> <span class="o">=</span> <span class="n">client_name</span>
        <span class="k">if</span> <span class="n">lease_current</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span> <span class="o">=</span> <span class="n">lease_current</span>
        <span class="k">elif</span> <span class="n">lease</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_original</span><span class="o">.</span><span class="n">create_sublease</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">client_name</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span> <span class="o">=</span> <span class="kc">None</span>

<div class="viewcode-block" id="LeaseState.create_newer"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseState.create_newer">[docs]</a>    <span class="k">def</span> <span class="nf">create_newer</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Create newer version of the Lease.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Instance of itself if lease_current was not passed, or a new LeaseState.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span>
        <span class="k">return</span> <span class="n">LeaseState</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_status</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_owner</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_original</span><span class="p">,</span>
                          <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="o">.</span><span class="n">create_newer</span><span class="p">())</span></div>

<div class="viewcode-block" id="LeaseState.update_from_lease_use_result"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseState.update_from_lease_use_result">[docs]</a>    <span class="k">def</span> <span class="nf">update_from_lease_use_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_use_result</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Update internal instance of LeaseState from given lease.</span>

<span class="sd">        Args:</span>
<span class="sd">            lease_use_result: LeaseUseResult from the server.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Updated internal instance of LeaseState.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">STATUS_OLDER</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">:</span>
                <span class="n">latest_known_lease</span> <span class="o">=</span> <span class="n">Lease</span><span class="p">(</span><span class="n">lease_use_result</span><span class="o">.</span><span class="n">latest_known_lease</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">latest_known_lease</span><span class="o">.</span><span class="n">is_valid_lease</span><span class="p">():</span>
                    <span class="n">cmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="o">.</span><span class="n">compare</span><span class="p">(</span><span class="n">latest_known_lease</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">cmp</span> <span class="ow">is</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">NEWER</span> <span class="ow">or</span> <span class="n">cmp</span> <span class="ow">is</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SAME</span><span class="p">:</span>
                        <span class="c1"># The attempted lease was older, but the lease in the wallet has been updated</span>
                        <span class="c1"># in the meantime to something that is newer than what the robot has seen, so</span>
                        <span class="c1"># this OLDER result is no longer relevant.</span>
                        <span class="k">return</span> <span class="bp">self</span>
                <span class="c1"># The lease from the lease wallet was an older lease.</span>
                <span class="k">return</span> <span class="n">LeaseState</span><span class="p">(</span><span class="n">LeaseState</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">OTHER_OWNER</span><span class="p">,</span> <span class="n">lease_owner</span><span class="o">=</span><span class="n">lease_use_result</span><span class="o">.</span><span class="n">owner</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">STATUS_WRONG_EPOCH</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">:</span>
                <span class="n">attempted_lease</span> <span class="o">=</span> <span class="n">Lease</span><span class="p">(</span><span class="n">lease_use_result</span><span class="o">.</span><span class="n">attempted_lease</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">attempted_lease</span><span class="o">.</span><span class="n">compare</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">)</span> <span class="ow">is</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SAME</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">LeaseState</span><span class="p">(</span><span class="n">LeaseState</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">UNOWNED</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">STATUS_REVOKED</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">:</span>
                <span class="n">attempted_lease</span> <span class="o">=</span> <span class="n">Lease</span><span class="p">(</span><span class="n">lease_use_result</span><span class="o">.</span><span class="n">attempted_lease</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">attempted_lease</span><span class="o">.</span><span class="n">compare</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_current</span><span class="p">)</span> <span class="ow">is</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SAME</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">LeaseState</span><span class="p">(</span><span class="n">LeaseState</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">REVOKED</span><span class="p">)</span>
        <span class="c1"># The LeaseState is not modified</span>
        <span class="k">return</span> <span class="bp">self</span></div></div>


<span class="n">_RESOURCE_BODY</span> <span class="o">=</span> <span class="s1">&#39;body&#39;</span>


<div class="viewcode-block" id="LeaseWallet"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet">[docs]</a><span class="k">class</span> <span class="nc">LeaseWallet</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Thread-safe storage of Leases.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Lock</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">client_name</span> <span class="o">=</span> <span class="kc">None</span>

<div class="viewcode-block" id="LeaseWallet.add"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.add">[docs]</a>    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Add lease in the wallet.</span>

<span class="sd">        Args:</span>
<span class="sd">            lease: Lease to add in the wallet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_add_lease_locked</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_add_lease_locked</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">,</span> <span class="n">current</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="n">resource</span> <span class="o">=</span> <span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">resource</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="p">[</span><span class="n">resource</span><span class="p">]</span> <span class="o">=</span> <span class="n">LeaseState</span><span class="p">(</span><span class="n">LeaseState</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">SELF_OWNER</span><span class="p">,</span> <span class="n">lease</span><span class="o">=</span><span class="n">lease</span><span class="p">,</span>
                                                     <span class="n">client_name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">client_name</span><span class="p">)</span>

<div class="viewcode-block" id="LeaseWallet.remove"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.remove">[docs]</a>    <span class="k">def</span> <span class="nf">remove</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Remove lease from the wallet.</span>

<span class="sd">        Args:</span>
<span class="sd">            lease: Lease to remove from the wallet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="o">.</span><span class="n">resource</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseWallet.advance"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.advance">[docs]</a>    <span class="k">def</span> <span class="nf">advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Advance the lease for a specific resource.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: The resource that the Lease is for.</span>
<span class="sd">        Returns:</span>
<span class="sd">            Advanced lease for the resource.</span>
<span class="sd">        Raises:</span>
<span class="sd">            LeaseNotOwnedByWallet: The lease is not owned by the wallet.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="n">lease_state</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_owned_lease_state_locked</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
            <span class="n">new_lease</span> <span class="o">=</span> <span class="n">lease_state</span><span class="o">.</span><span class="n">create_newer</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="p">[</span><span class="n">resource</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_lease</span>
            <span class="k">return</span> <span class="n">new_lease</span><span class="o">.</span><span class="n">lease_current</span></div>

<div class="viewcode-block" id="LeaseWallet.get_lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.get_lease">[docs]</a>    <span class="k">def</span> <span class="nf">get_lease</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the lease for a specific resource.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: The resource that the Lease is for.</span>
<span class="sd">        Returns:</span>
<span class="sd">            Lease for the resource.</span>
<span class="sd">        Raises:</span>
<span class="sd">            LeaseNotOwnedByWallet: The lease is not owned by the wallet.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_owned_lease_state_locked</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span><span class="o">.</span><span class="n">lease_current</span></div>

<div class="viewcode-block" id="LeaseWallet.get_lease_state"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.get_lease_state">[docs]</a>    <span class="k">def</span> <span class="nf">get_lease_state</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the lease state for a specific resource.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: The resource that the Lease is for.</span>
<span class="sd">        Returns:</span>
<span class="sd">            Lease state for the resource.</span>
<span class="sd">        Raises:</span>
<span class="sd">            NoSuchLease: The requested lease does not exist.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_lease_state_locked</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_get_lease_state_locked</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the lease state for a specific resource or raise an NoSuchLease exception if lease</span>
<span class="sd">        is not found.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: The resource that the Lease is for.</span>
<span class="sd">        Returns:</span>
<span class="sd">            Lease state for the resource.</span>
<span class="sd">        Raises:</span>
<span class="sd">            NoSuchLease: The requested lease does not exist.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="p">[</span><span class="n">resource</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">NoSuchLease</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_get_owned_lease_state_locked</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get the lease for a specific resource or raise an LeaseNotOwnedByWallet exception if</span>
<span class="sd">        lease is not found.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: The resource that the Lease is for.</span>
<span class="sd">        Returns:</span>
<span class="sd">            Lease state for the resource.</span>
<span class="sd">        Raises:</span>
<span class="sd">            LeaseNotOwnedByWallet: The lease is not owned by the wallet.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">lease_state</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_lease_state_locked</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">lease_state</span><span class="o">.</span><span class="n">lease_status</span> <span class="o">!=</span> <span class="n">LeaseState</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">SELF_OWNER</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">LeaseNotOwnedByWallet</span><span class="p">(</span><span class="n">resource</span><span class="p">,</span> <span class="n">lease_state</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">lease_state</span>

<div class="viewcode-block" id="LeaseWallet.on_lease_use_result"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.on_lease_use_result">[docs]</a>    <span class="k">def</span> <span class="nf">on_lease_use_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_use_result</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Update the lease state based on result of using the lease.</span>

<span class="sd">        Args:</span>
<span class="sd">          lease_use_result: LeaseUseResult from the server.</span>
<span class="sd">          resource: Resource to update, e.g. &#39;body&#39;. Default to None to use the resource specified</span>
<span class="sd">                          by the lease_use_result.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">resource</span> <span class="o">=</span> <span class="n">resource</span> <span class="ow">or</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">attempted_lease</span><span class="o">.</span><span class="n">resource</span>
        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="n">lease_state</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">resource</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">lease_state</span><span class="p">:</span>
                <span class="k">return</span>
            <span class="n">new_lease_state</span> <span class="o">=</span> <span class="n">lease_state</span><span class="o">.</span><span class="n">update_from_lease_use_result</span><span class="p">(</span><span class="n">lease_use_result</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_lease_state_map</span><span class="p">[</span><span class="n">resource</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_lease_state</span></div>

<div class="viewcode-block" id="LeaseWallet.set_client_name"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWallet.set_client_name">[docs]</a>    <span class="k">def</span> <span class="nf">set_client_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">client_name</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Set the client name that will be issuing the leases.&quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lock</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">client_name</span> <span class="o">=</span> <span class="n">client_name</span></div></div>


<div class="viewcode-block" id="LeaseClient"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient">[docs]</a><span class="k">class</span> <span class="nc">LeaseClient</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">BaseClient</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Client to the lease service.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_wallet: Lease wallet to use.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">default_service_name</span> <span class="o">=</span> <span class="s1">&#39;lease&#39;</span>
    <span class="n">service_type</span> <span class="o">=</span> <span class="s1">&#39;bosdyn.api.LeaseService&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_wallet</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LeaseClient</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">LeaseServiceStub</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span> <span class="o">=</span> <span class="n">lease_wallet</span>

<div class="viewcode-block" id="LeaseClient.acquire"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.acquire">[docs]</a>    <span class="k">def</span> <span class="nf">acquire</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Acquire a lease for the given resource.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: Resource for the lease.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Acquired Lease object.</span>

<span class="sd">        Raises:</span>
<span class="sd">            ResourceAlreadyClaimedError: Use TakeLease method to forcefully grab the already</span>
<span class="sd">                                         claimed lease.</span>
<span class="sd">            InvalidResourceError: Resource is not known to the LeaseService.</span>
<span class="sd">            NotAuthoritativeServiceError: LeaseService is not authoritative so Acquire should not work.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_acquire_request</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">AcquireLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_success</span><span class="p">,</span>
                         <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.acquire_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.acquire_async">[docs]</a>    <span class="k">def</span> <span class="nf">acquire_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of acquire() function.&quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_acquire_request</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call_async</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">AcquireLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_success</span><span class="p">,</span>
                               <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.take"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.take">[docs]</a>    <span class="k">def</span> <span class="nf">take</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Take the lease for the given resource.</span>

<span class="sd">        Args:</span>
<span class="sd">            resource: Resource for the lease.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Taken Lease object.</span>

<span class="sd">        Raises:</span>
<span class="sd">            InvalidResourceError: Resource is not known to the LeaseService.</span>
<span class="sd">            NotAuthoritativeServiceError: LeaseService is not authoritative so Acquire should not</span>
<span class="sd">                                          work.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_take_request</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">TakeLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_success</span><span class="p">,</span>
                         <span class="bp">self</span><span class="o">.</span><span class="n">_handle_take_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.take_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.take_async">[docs]</a>    <span class="k">def</span> <span class="nf">take_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of the take() function.&quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_take_request</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call_async</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">TakeLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_acquire_success</span><span class="p">,</span>
                               <span class="bp">self</span><span class="o">.</span><span class="n">_handle_take_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.return_lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.return_lease">[docs]</a>    <span class="k">def</span> <span class="nf">return_lease</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return an acquired lease.</span>

<span class="sd">        Args:</span>
<span class="sd">            lease (Lease object): Lease to return. This should be a Lease class object, and not the proto.</span>

<span class="sd">        Raises:</span>
<span class="sd">            InvalidResourceError: Resource is not known to the LeaseService.</span>
<span class="sd">            NotActiveLeaseError: Lease is not the active lease.</span>
<span class="sd">            NotAuthoritativeServiceError: LeaseService is not authoritative so Acquire should not</span>
<span class="sd">                                          work.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_return_request</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ReturnLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_return_errors</span><span class="p">,</span>
                         <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.return_lease_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.return_lease_async">[docs]</a>    <span class="k">def</span> <span class="nf">return_lease_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of the return_lease() function.&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_return_request</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ReturnLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_handle_return_errors</span><span class="p">,</span>
                         <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.retain_lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.retain_lease">[docs]</a>    <span class="k">def</span> <span class="nf">retain_lease</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Retain the lease.</span>

<span class="sd">        Args:</span>
<span class="sd">            lease: Lease to retain.</span>

<span class="sd">        Raises:</span>
<span class="sd">            InternalServerError: Service experienced an unexpected error state.</span>
<span class="sd">            LeaseUseError: Request was rejected due to using an invalid lease.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_retain_request</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">RetainLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">common_lease_errors</span><span class="p">,</span>
                         <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.retain_lease_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.retain_lease_async">[docs]</a>    <span class="k">def</span> <span class="nf">retain_lease_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of the retain_lease() function.&quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_retain_request</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call_async</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">RetainLease</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">common_lease_errors</span><span class="p">,</span>
                               <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="LeaseClient.list_leases"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.list_leases">[docs]</a>    <span class="k">def</span> <span class="nf">list_leases</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">include_full_lease_info</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get a list of the leases.</span>

<span class="sd">        Args:</span>
<span class="sd">            include_full_lease_info: Whether the returned list of LeaseResources should include</span>
<span class="sd">                                     all of the available information about the last lease used.</span>
<span class="sd">                                     Defaults to False.</span>

<span class="sd">        Returns:</span>
<span class="sd">            List of lease resources.</span>

<span class="sd">        Raises:</span>
<span class="sd">            InternalServerError: Service experienced an unexpected error state.</span>
<span class="sd">            LeaseUseError: Request was rejected due to using an invalid lease.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_list_leases_request</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ListLeases</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_list_leases_success</span><span class="p">,</span>
                         <span class="n">common</span><span class="o">.</span><span class="n">common_header_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.list_leases_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.list_leases_async">[docs]</a>    <span class="k">def</span> <span class="nf">list_leases_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">include_full_lease_info</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of the list_leases() function.&quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_list_leases_request</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call_async</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ListLeases</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_list_leases_success</span><span class="p">,</span>
                               <span class="n">common</span><span class="o">.</span><span class="n">common_header_errors</span><span class="p">,</span> <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.list_leases_full"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.list_leases_full">[docs]</a>    <span class="k">def</span> <span class="nf">list_leases_full</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">include_full_lease_info</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get a list of the leases.</span>

<span class="sd">        Args:</span>
<span class="sd">            include_full_lease_info: Whether the returned list of LeaseResources should include</span>
<span class="sd">                                     all of the available information about the last lease used.</span>
<span class="sd">                                     Defaults to False.</span>

<span class="sd">        Returns:</span>
<span class="sd">            The complete ListLeasesResponse message.</span>

<span class="sd">        Raises:</span>
<span class="sd">            InternalServerError: Service experienced an unexpected error state.</span>
<span class="sd">            LeaseUseError: Request was rejected due to using an invalid lease.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_list_leases_request</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ListLeases</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">common_header_errors</span><span class="p">,</span>
                         <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseClient.list_leases_full_async"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseClient.list_leases_full_async">[docs]</a>    <span class="k">def</span> <span class="nf">list_leases_full_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">include_full_lease_info</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Async version of the list_leases() function.&quot;&quot;&quot;</span>
        <span class="n">req</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_list_leases_request</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="p">)</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">call_async</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_stub</span><span class="o">.</span><span class="n">ListLeases</span><span class="p">,</span> <span class="n">req</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">common_header_errors</span><span class="p">,</span>
                               <span class="n">copy_request</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_make_acquire_request</span><span class="p">(</span><span class="n">resource</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return AcquireLeaseRequest message with the given resource.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">AcquireLeaseRequest</span><span class="p">(</span><span class="n">resource</span><span class="o">=</span><span class="n">resource</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_handle_acquire_success</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return lease in an AcquireLeaseResponse message.&quot;&quot;&quot;</span>
        <span class="n">lease</span> <span class="o">=</span> <span class="n">Lease</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">lease</span>

    <span class="nd">@staticmethod</span>
    <span class="nd">@common</span><span class="o">.</span><span class="n">handle_common_header_errors</span>
    <span class="k">def</span> <span class="nf">_handle_acquire_errors</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a custom exception based on response, None if no error.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">common</span><span class="o">.</span><span class="n">error_factory</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span>
                                    <span class="n">status_to_string</span><span class="o">=</span><span class="n">AcquireLeaseResponse</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">,</span>
                                    <span class="n">status_to_error</span><span class="o">=</span><span class="n">_ACQUIRE_LEASE_STATUS_TO_ERROR</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_make_take_request</span><span class="p">(</span><span class="n">resource</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return TakeLeaseRequest message with the given resource.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">TakeLeaseRequest</span><span class="p">(</span><span class="n">resource</span><span class="o">=</span><span class="n">resource</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="nd">@common</span><span class="o">.</span><span class="n">handle_common_header_errors</span>
    <span class="k">def</span> <span class="nf">_handle_take_errors</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a custom exception based on response, None if no error.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">common</span><span class="o">.</span><span class="n">error_factory</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span>
                                    <span class="n">status_to_string</span><span class="o">=</span><span class="n">TakeLeaseResponse</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">,</span>
                                    <span class="n">status_to_error</span><span class="o">=</span><span class="n">_TAKE_LEASE_STATUS_TO_ERROR</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_make_return_request</span><span class="p">(</span><span class="n">lease</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ReturnLeaseRequest</span><span class="p">(</span><span class="n">lease</span><span class="o">=</span><span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="nd">@common</span><span class="o">.</span><span class="n">handle_common_header_errors</span>
    <span class="k">def</span> <span class="nf">_handle_return_errors</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Return a custom exception based on response, None if no error.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">common</span><span class="o">.</span><span class="n">error_factory</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span>
                                    <span class="n">status_to_string</span><span class="o">=</span><span class="n">ReturnLeaseResponse</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">,</span>
                                    <span class="n">status_to_error</span><span class="o">=</span><span class="n">_RETURN_LEASE_STATUS_TO_ERROR</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_make_retain_request</span><span class="p">(</span><span class="n">lease</span><span class="p">):</span>
        <span class="n">req</span> <span class="o">=</span> <span class="n">RetainLeaseRequest</span><span class="p">(</span><span class="n">lease</span><span class="o">=</span><span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">req</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_make_list_leases_request</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ListLeasesRequest</span><span class="p">(</span><span class="n">include_full_lease_info</span><span class="o">=</span><span class="n">include_full_lease_info</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_list_leases_success</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">resources</span></div>


<span class="c1"># Constant to be explicit about using the default resources that a processor was initialized with,</span>
<span class="c1"># rather than using None to imply that.</span>
<span class="n">DEFAULT_RESOURCES</span> <span class="o">=</span> <span class="nb">object</span><span class="p">()</span>


<div class="viewcode-block" id="LeaseWalletRequestProcessor"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWalletRequestProcessor">[docs]</a><span class="k">class</span> <span class="nc">LeaseWalletRequestProcessor</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;LeaseWalletRequestProcessor adds a lease from a wallet to a request.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_wallet: The LeaseWallet to read leases from.</span>
<span class="sd">        resource_list: List of resources this processor should add to requests. Default None</span>
<span class="sd">                        to use the default resource.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_wallet</span><span class="p">,</span> <span class="n">resource_list</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span> <span class="o">=</span> <span class="n">lease_wallet</span>
        <span class="k">if</span> <span class="n">resource_list</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">resource_list</span> <span class="o">=</span> <span class="p">(</span><span class="n">_RESOURCE_BODY</span><span class="p">,)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">resource_list</span> <span class="o">=</span> <span class="n">resource_list</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span>

<div class="viewcode-block" id="LeaseWalletRequestProcessor.mutate"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWalletRequestProcessor.mutate">[docs]</a>    <span class="k">def</span> <span class="nf">mutate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">resource_list</span><span class="o">=</span><span class="n">DEFAULT_RESOURCES</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Add the leases for the necessary resources if no leases have been specified yet.&quot;&quot;&quot;</span>
        <span class="n">multiple_leases</span><span class="p">,</span> <span class="n">skip_mutation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_lease_state</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">skip_mutation</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="k">if</span> <span class="n">resource_list</span> <span class="ow">is</span> <span class="n">DEFAULT_RESOURCES</span><span class="p">:</span>
            <span class="n">resource_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">resource_list</span>

        <span class="k">if</span> <span class="n">multiple_leases</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">resource_list</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">pass</span>
        <span class="k">elif</span> <span class="ow">not</span> <span class="n">multiple_leases</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">resource_list</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">&#39;LeaseWalletRequestProcessor assigned multiple leases, &#39;</span>
                              <span class="s1">&#39;but request only wants one&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">multiple_leases</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">resource</span> <span class="ow">in</span> <span class="n">resource_list</span><span class="p">:</span>
                <span class="n">lease</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">advance</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span>
                <span class="n">request</span><span class="o">.</span><span class="n">leases</span><span class="o">.</span><span class="n">add</span><span class="p">()</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">lease</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">advance</span><span class="p">(</span><span class="n">resource_list</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="n">request</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseWalletRequestProcessor.get_lease_state"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWalletRequestProcessor.get_lease_state">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_lease_state</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Returns a tuple of (&quot;are there multiple leases in request?&quot;, &quot;are they set already?&quot;)&quot;&quot;&quot;</span>
        <span class="n">skip_mutation</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">multiple_leases</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="c1"># ValueError will occur if the request class does not have a field named &#39;lease&#39;</span>
            <span class="n">skip_mutation</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">HasField</span><span class="p">(</span><span class="s1">&#39;lease&#39;</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="c1"># AttributeError will occur if the request class does not have a field named &#39;leases&#39;</span>
                <span class="n">skip_mutation</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">leases</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span>
            <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                <span class="c1"># If we get here, there&#39;s no &#39;lease&#39; field nor a &#39;leases&#39; field.</span>
                <span class="c1"># There are responses that do not have either field, so just return.</span>
                <span class="n">skip_mutation</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">multiple_leases</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># If we get here, there&#39;s only a single lease.</span>
            <span class="n">multiple_leases</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">return</span> <span class="n">multiple_leases</span><span class="p">,</span> <span class="n">skip_mutation</span></div></div>


<div class="viewcode-block" id="LeaseWalletResponseProcessor"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWalletResponseProcessor">[docs]</a><span class="k">class</span> <span class="nc">LeaseWalletResponseProcessor</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;LeaseWalletResponseProcessor updates the wallet with a LeaseUseResult.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_wallet: Lease wallet to use.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_wallet</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span> <span class="o">=</span> <span class="n">lease_wallet</span>

<div class="viewcode-block" id="LeaseWalletResponseProcessor.mutate"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseWalletResponseProcessor.mutate">[docs]</a>    <span class="k">def</span> <span class="nf">mutate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Update the wallet if a response has a lease_use_result.&quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="c1"># AttributeError will occur if the response does not have a field named &#39;lease_use_result&#39;</span>
            <span class="n">lease_use_results</span> <span class="o">=</span> <span class="p">[</span><span class="n">response</span><span class="o">.</span><span class="n">lease_use_result</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="c1"># AttributeError will occur if the request class does not have a field named &#39;lease_use_results&#39;</span>
                <span class="n">lease_use_results</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">lease_use_results</span>
            <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                <span class="c1"># If we get here, there&#39;s no &#39;lease&#39; field nor a &#39;leases&#39; field for usage results.</span>
                <span class="c1"># There are responses that do not have either field, so just return.</span>
                <span class="k">return</span>

        <span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">lease_use_results</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">on_lease_use_result</span><span class="p">(</span><span class="n">result</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="add_lease_wallet_processors"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.add_lease_wallet_processors">[docs]</a><span class="k">def</span> <span class="nf">add_lease_wallet_processors</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">lease_wallet</span><span class="p">,</span> <span class="n">resource_list</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Adds LeaseWallet related processors to a gRPC client.</span>

<span class="sd">    For services which use leases for access control, this does two things:</span>
<span class="sd">        * Advance the lease from the LeaseWallet and attach to a request.</span>
<span class="sd">        * Handle the LeaseUseResult from a response and update LeaseWallet.</span>

<span class="sd">    Args:</span>
<span class="sd">        * client: BaseClient derived class for a single service.</span>
<span class="sd">        * lease_wallet: The LeaseWallet to track from, must be non-None.</span>
<span class="sd">        * resource_list: List of resources these processors should add to requests. Default None</span>
<span class="sd">                             to use a default resource.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">client</span><span class="o">.</span><span class="n">request_processors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">LeaseWalletRequestProcessor</span><span class="p">(</span><span class="n">lease_wallet</span><span class="p">,</span> <span class="n">resource_list</span><span class="p">))</span>
    <span class="n">client</span><span class="o">.</span><span class="n">response_processors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">LeaseWalletResponseProcessor</span><span class="p">(</span><span class="n">lease_wallet</span><span class="p">))</span></div>


<div class="viewcode-block" id="LeaseKeepAlive"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseKeepAlive">[docs]</a><span class="k">class</span> <span class="nc">LeaseKeepAlive</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;LeaseKeepAlive issues lease liveness checks on a background thread.</span>

<span class="sd">    The robot&#39;s lease system expects lease-holders to check in at a regular</span>
<span class="sd">    cadence. If the check-ins do not happen, the robot will treat it as a</span>
<span class="sd">    communications loss. Typically this will result in the robot stopping,</span>
<span class="sd">    powering off, and the lease-holder getting their lease revoked.</span>

<span class="sd">    Using a LeaseKeepAlive object hides most of the details of issuing the</span>
<span class="sd">    lease liveness check. Developers can also manage liveness checks directly</span>
<span class="sd">    by using the retain_lease methods on the LeaseClient object.</span>

<span class="sd">    Args:</span>
<span class="sd">        lease_client: The LeaseClient object to issue requests on.</span>
<span class="sd">        lease_wallet: The LeaseWallet to retrieve current leases from,</span>
<span class="sd">                and to handle any bad LeaseUseResults from. If not specified,</span>
<span class="sd">                the lease_client&#39;s lease_wallet will be used.</span>
<span class="sd">        resource: The resource to do liveness checks for.</span>
<span class="sd">        rpc_interval_seconds: Duration in seconds between liveness checks.</span>
<span class="sd">        keep_running_cb: If specified, should be a callable object that</span>
<span class="sd">                returns True if the liveness checks should proceed, False</span>
<span class="sd">                otherwise. LeaseKeepAlive will invoke keep_running_cb on its</span>
<span class="sd">                background thread. One example of where this could be used is</span>
<span class="sd">                in an interactive UI - keep_running_cb could stall or return</span>
<span class="sd">                False if the UI thread is wedged, which prevents the</span>
<span class="sd">                application from continuing to keep the Lease alive when it is</span>
<span class="sd">                no longer in a good state.</span>
<span class="sd">        on_failure_callback: If specified, this should be a callable function object</span>
<span class="sd">                which takes the error/exception as an input. The  function does not</span>
<span class="sd">                need to return anything. This function can be used to action on any</span>
<span class="sd">                failures during the keepalive from the RetainLease RPC.</span>
<span class="sd">        warnings(bool): Used to determine if the _periodic_check_in function will print lease check-in errors.</span>
<span class="sd">        must_acquire(bool): If True, exceptions when trying to acquire the lease will not be caught.</span>
<span class="sd">        return_at_exit(bool): If True, return the lease when shutting down.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lease_client</span><span class="p">,</span> <span class="n">lease_wallet</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">resource</span><span class="o">=</span><span class="n">_RESOURCE_BODY</span><span class="p">,</span>
                 <span class="n">rpc_interval_seconds</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">keep_running_cb</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">host_name</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
                 <span class="n">on_failure_callback</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">warnings</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">must_acquire</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">return_at_exit</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Create a new LeaseKeepAlive object.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">host_name</span> <span class="o">=</span> <span class="n">host_name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">print_warnings</span> <span class="o">=</span> <span class="n">warnings</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_return_at_exit</span> <span class="o">=</span> <span class="n">return_at_exit</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">lease_client</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;lease_client must be set&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_lease_client</span> <span class="o">=</span> <span class="n">lease_client</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">lease_wallet</span><span class="p">:</span>
            <span class="n">lease_wallet</span> <span class="o">=</span> <span class="n">lease_client</span><span class="o">.</span><span class="n">lease_wallet</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">lease_wallet</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;lease_wallet must be set&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_lease_wallet</span> <span class="o">=</span> <span class="n">lease_wallet</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">resource</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;resource must be set&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_resource</span> <span class="o">=</span> <span class="n">resource</span>

        <span class="c1"># If we don&#39;t have the lease, acquire it.</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_lease_wallet</span><span class="o">.</span><span class="n">get_lease</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_resource</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">Error</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_lease_client</span><span class="o">.</span><span class="n">acquire</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_resource</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">BaseError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">must_acquire</span><span class="p">:</span>
                    <span class="k">raise</span>
                <span class="n">_LOGGER</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">&#39;Failed to acquire the lease in LeaseKeepAlive: </span><span class="si">%s</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">exc</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">rpc_interval_seconds</span> <span class="o">&lt;=</span> <span class="mf">0.0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;rpc_interval_seconds must be &gt; 0, was </span><span class="si">%f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">rpc_interval_seconds</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_rpc_interval_seconds</span> <span class="o">=</span> <span class="n">rpc_interval_seconds</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_keep_running</span> <span class="o">=</span> <span class="n">keep_running_cb</span> <span class="ow">or</span> <span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="kc">True</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_end_check_in_signal</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>

        <span class="c1"># If the on_failure_callback is not provided, then set the default as a no-op function.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_retain_lease_failed_cb</span> <span class="o">=</span> <span class="n">on_failure_callback</span> <span class="ow">or</span> <span class="p">(</span><span class="k">lambda</span> <span class="n">err</span><span class="p">:</span> <span class="kc">None</span><span class="p">)</span>

        <span class="c1"># Configure the thread to do check-ins, and begin checking in.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_thread</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_periodic_check_in</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_thread</span><span class="o">.</span><span class="n">daemon</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_thread</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>

<div class="viewcode-block" id="LeaseKeepAlive.shutdown"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseKeepAlive.shutdown">[docs]</a>    <span class="k">def</span> <span class="nf">shutdown</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Shut the background thread down and stop the liveness checks.</span>

<span class="sd">        Can be called multiple times, but subsequent calls are no-ops.</span>
<span class="sd">        Blocks until the background thread completes.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Shutting down&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_end_periodic_check_in</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">wait_until_done</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_return_at_exit</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_lease_client</span><span class="o">.</span><span class="n">return_lease</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lease_wallet</span><span class="o">.</span><span class="n">get_lease</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_resource</span><span class="p">),</span>
                                                <span class="n">timeout</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">except</span> <span class="p">(</span><span class="n">LeaseResponseError</span><span class="p">,</span> <span class="n">NoSuchLease</span><span class="p">,</span> <span class="n">LeaseNotOwnedByWallet</span><span class="p">):</span>
                <span class="k">pass</span>  <span class="c1"># These all mean that we don&#39;t own the lease anymore, which is fine.</span>
            <span class="k">except</span> <span class="n">RpcError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
                <span class="n">_LOGGER</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">&#39;Failed to return the lease at the end: </span><span class="si">%s</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">exc</span><span class="p">)</span></div>

<div class="viewcode-block" id="LeaseKeepAlive.is_alive"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseKeepAlive.is_alive">[docs]</a>    <span class="k">def</span> <span class="nf">is_alive</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_thread</span><span class="o">.</span><span class="n">is_alive</span><span class="p">()</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">lease_wallet</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lease_wallet</span>

<div class="viewcode-block" id="LeaseKeepAlive.wait_until_done"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.LeaseKeepAlive.wait_until_done">[docs]</a>    <span class="k">def</span> <span class="nf">wait_until_done</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Waits until the background thread exits.</span>

<span class="sd">        Most client code should exit the background thread by using shutdown</span>
<span class="sd">        or by passing in a keep_running_cb callback in the constructor.</span>

<span class="sd">        However, this can be useful in unit tests for ensuring exits.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_thread</span><span class="o">.</span><span class="n">join</span><span class="p">()</span></div>

    <span class="k">def</span> <span class="nf">_end_periodic_check_in</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Stop checking into the Lease system.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Stopping check-in&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_end_check_in_signal</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span>

    <span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_val</span><span class="p">,</span> <span class="n">exc_tb</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_ok</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Check-in successful&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_check_in</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Retain lease associated with the resource in this class.&quot;&quot;&quot;</span>
        <span class="n">lease</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lease_wallet</span><span class="o">.</span><span class="n">get_lease</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_resource</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">lease</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lease_client</span><span class="o">.</span><span class="n">retain_lease</span><span class="p">(</span><span class="n">lease</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_periodic_check_in</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Periodically check in and retain the lease associated with the resource in this class.&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Starting lease check-in&#39;</span><span class="p">)</span>
        <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
            <span class="c1"># Include the time it takes to execute keep_running, in case it takes a significant</span>
            <span class="c1"># portion of our check in period.</span>
            <span class="n">exec_start</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>

            <span class="c1"># Stop doing retention if this is not meant to keep running.</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_keep_running</span><span class="p">():</span>
                <span class="k">break</span>

            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_check_in</span><span class="p">()</span>
            <span class="c1"># We really do want to catch anything.</span>
            <span class="c1">#pylint: disable=broad-except</span>
            <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">print_warnings</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
                        <span class="s1">&#39;Generic exception for </span><span class="si">%s</span><span class="s1"> during check-in:</span><span class="se">\n</span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span>
                        <span class="s1">&#39;    (resuming check-in)&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">host_name</span><span class="p">,</span> <span class="n">exc</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_retain_lease_failed_cb</span><span class="p">(</span><span class="n">exc</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="c1"># No errors!</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_ok</span><span class="p">()</span>

            <span class="c1"># How long did the RPC and processing of said RPC take?</span>
            <span class="n">exec_seconds</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">exec_start</span>

            <span class="c1"># Block and wait for the stop signal. If we receive it within the check-in period,</span>
            <span class="c1"># leave the loop. This check must be at the end of the loop!</span>
            <span class="c1"># Wait up to self._check_in_period seconds, minus the RPC processing time.</span>
            <span class="c1"># (values &lt; 0 are OK and will return immediately)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end_check_in_signal</span><span class="o">.</span><span class="n">wait</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_rpc_interval_seconds</span> <span class="o">-</span> <span class="n">exec_seconds</span><span class="p">):</span>
                <span class="k">break</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Lease check-in stopped&#39;</span><span class="p">)</span></div>


<div class="viewcode-block" id="test_active_lease"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html#bosdyn.client.lease.test_active_lease">[docs]</a><span class="k">def</span> <span class="nf">test_active_lease</span><span class="p">(</span><span class="n">incoming_lease_proto</span><span class="p">,</span> <span class="n">active_lease</span><span class="p">,</span> <span class="n">sublease_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                      <span class="n">allow_super_leases</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Check if an incoming lease is newer than the current lease.</span>

<span class="sd">    Args:</span>
<span class="sd">        incoming_lease_proto(lease_pb2.Lease): The incoming lease proto.</span>
<span class="sd">        active_lease(Lease): A lease object representing the most recent/newest known lease</span>
<span class="sd">                             that the incoming lease should be compared against.</span>
<span class="sd">        sublease_name(string): If not NoneType, a sublease of the incoming lease will be</span>
<span class="sd">                             created (with sublease_name as the client name) and used to compare to</span>
<span class="sd">                             the active lease.</span>
<span class="sd">        allow_super_leases(boolean): If true, a super lease will still be considered as &quot;ok&quot;/</span>
<span class="sd">                                     newer when compared to the active lease.</span>

<span class="sd">    Returns:</span>
<span class="sd">        A tuple containing the lease use result from comparing the incoming and active leases, and</span>
<span class="sd">        then a Lease object made from the incoming lease proto. The lease object will be None if</span>
<span class="sd">        the incoming lease proto was invalid. The lease object will be a sublease of the incoming</span>
<span class="sd">        lease proto if sublease_name is not NoneType.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">lease_use_result</span> <span class="o">=</span> <span class="n">LeaseUseResult</span><span class="p">()</span>
    <span class="n">lease_use_result</span><span class="o">.</span><span class="n">attempted_lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">incoming_lease_proto</span><span class="p">)</span>

    <span class="c1"># Ensure the incoming lease is valid. If it is valid, create a sublease for the</span>
    <span class="c1"># incoming lease and test with that.</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">incoming_lease</span> <span class="o">=</span> <span class="n">Lease</span><span class="p">(</span><span class="n">incoming_lease_proto</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">sublease_name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">incoming_lease</span> <span class="o">=</span> <span class="n">incoming_lease</span><span class="o">.</span><span class="n">create_sublease</span><span class="p">(</span><span class="n">client_name</span><span class="o">=</span><span class="n">sublease_name</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="c1"># Invalid lease proto will throw this error.</span>
        <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">=</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_INVALID_LEASE</span>
        <span class="k">return</span> <span class="n">lease_use_result</span><span class="p">,</span> <span class="kc">None</span>

    <span class="k">if</span> <span class="n">active_lease</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="c1"># No active lease means that the incoming lease is good!</span>
        <span class="c1"># Set the incoming lease proto as the latest known lease. There will be no previous</span>
        <span class="c1"># lease since this is the first one for the resource.</span>
        <span class="n">lease_use_result</span><span class="o">.</span><span class="n">latest_known_lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">incoming_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
        <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">=</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OK</span>
        <span class="k">return</span> <span class="n">lease_use_result</span><span class="p">,</span> <span class="n">incoming_lease</span>

    <span class="c1"># Ensure the active lease is also valid.</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">active_lease</span><span class="o">.</span><span class="n">is_valid_lease</span><span class="p">():</span>
        <span class="c1"># Raise an exception since the incoming lease is invalid.</span>
        <span class="k">raise</span> <span class="n">Error</span><span class="p">(</span><span class="s2">&quot;The active lease object is invalid.&quot;</span><span class="p">)</span>

    <span class="c1"># Set the previous lease as the active lease.</span>
    <span class="n">lease_use_result</span><span class="o">.</span><span class="n">previous_lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">active_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>

    <span class="c1"># Set the latest known lease as the active lease. This will be overwritten if the incoming</span>
    <span class="c1"># lease is found to be newer.</span>
    <span class="n">lease_use_result</span><span class="o">.</span><span class="n">latest_known_lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">active_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>

    <span class="c1"># Compare the incoming lease&#39;s sublease to the latest known/most recent lease (active lease).</span>
    <span class="n">compare_result</span> <span class="o">=</span> <span class="n">incoming_lease</span><span class="o">.</span><span class="n">compare</span><span class="p">(</span><span class="n">active_lease</span><span class="p">)</span>
    <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">=</span> <span class="n">Lease</span><span class="o">.</span><span class="n">compare_result_to_lease_use_result_status</span><span class="p">(</span>
        <span class="n">compare_result</span><span class="p">,</span> <span class="n">allow_super_leases</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">lease_use_result</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">LeaseUseResult</span><span class="o">.</span><span class="n">STATUS_OK</span> <span class="ow">and</span> <span class="n">compare_result</span> <span class="o">!=</span> <span class="n">Lease</span><span class="o">.</span><span class="n">CompareResult</span><span class="o">.</span><span class="n">SUPER_LEASE</span><span class="p">:</span>
        <span class="c1"># Only update the latest known lease if the incoming lease was found as status ok (newer/the same</span>
        <span class="c1"># as the existing lease). Also prevents a &quot;super-lease&quot; from getting set as the</span>
        <span class="c1"># latest known lease (when the allow_super_lease boolean is True) when there have been newer</span>
        <span class="c1"># subleases seen.</span>
        <span class="n">lease_use_result</span><span class="o">.</span><span class="n">latest_known_lease</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">incoming_lease</span><span class="o">.</span><span class="n">lease_proto</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">lease_use_result</span><span class="p">,</span> <span class="n">incoming_lease</span></div>
</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
      
      &copy; Copyright 2025 Boston Dynamics. All rights reserved.
      <a href="https://www.bostondynamics.com/privacy-policy">Privacy Policy</a> | 
      <a href="https://www.bostondynamics.com/terms">Terms of Use</a>

    </p>
  </div> 

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(false);
      });
  </script>
    <!-- Theme Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-XXXXXXX-1', {
          'anonymize_ip': false,
      });
    </script> 

</body>
</html>